let pic = document.querySelectorAll('.pic');
let left = document.querySelector('.left');
let right = document.querySelector('.right');
let button = document.querySelectorAll('.button');
let lastIndex = 0;


// console.log(pic);//打印出来图片的数组
pic.forEach(function(item, index) {

    console.log(item); //测试打印出来的是每个img

    right.onclick = function() {

        pic[lastIndex].classList.remove("block");
        item.classList.add('block');
        lastIndex = index;


    }

})